* get covered years
set more off 

forvalues b=2004/2013 {
	clear
	use /disk/aging/mktscan/nongeo/data/100pct/ccaet`b'
	*sample 1
	if `b'>2009 {
		drop year
	}
	gen month=month(dtstart)
	gen year=year(dtstart)
	keep if year==`b'
	keep if month<=12 & month>=1
	sort month
	by month: egen daysinmonth=max(memdays)
	tab daysinmonth
	gen pct_days_elig=memdays/daysinmonth
	sum pct_days_elig
	collapse (sum) pct_days_elig, by(month)
	format pct_days_elig %20.2g
	gen year=`b'
	save covered_months_`b', replace
	list
}

use covered_months_2004

forvalues b=2005/2013 {
	append using covered_months_`b'
}
save covered_months_all, replace
outsheet using covered_months_all.csv, comma replace
list

